import 'package:flutter/material.dart';

class AddressIndex extends StatelessWidget {
  const AddressIndex({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('收货地址管理', style: TextStyle(color: Colors.black)),
        backgroundColor: Colors.white,
        elevation: 0.5,
        centerTitle: true,
        iconTheme: const IconThemeData(color: Colors.black),
      ),
      backgroundColor: const Color(0xFFF5F5F5),
      body: Column(
        children: [
          // 地址卡片
          Container(
            margin: const EdgeInsets.all(16),
            padding: const EdgeInsets.all(16),
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.circular(12),
            ),
            child: Column(
              // 子元素在水平方向的对齐方式
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                // 姓名和电话
                Row(
                  children: const [
                    Text('姓名：', style: TextStyle(fontSize: 16)),
                    Text(
                      '15021459079',
                      style: TextStyle(
                        fontSize: 16,
                        fontWeight: FontWeight.bold,
                      ),
                    ),
                  ],
                ),
                const SizedBox(height: 8),
                // 地址
                const Text(
                  '北京 海淀区 中关村南（北京沙河校区）15号公寓',
                  style: TextStyle(fontSize: 15, color: Colors.black87),
                ),
                const SizedBox(height: 8),
                // 设为默认和删除
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Row(
                      children: [
                        Checkbox(
                          value: false,
                          onChanged: (v) {},
                          activeColor: Colors.red,
                          shape: CircleBorder(),
                        ),
                        Text('设为默认', style: TextStyle(fontSize: 14)),
                      ],
                    ),
                    TextButton(
                      onPressed: () {},
                      child: Text(
                        '删除',
                        style: TextStyle(color: Colors.black54),
                      ),
                    ),
                  ],
                ),
              ],
            ),
          ),
          // 自动填充空白，让新增按钮下来
          const Spacer(),
          // 新增收货地址按钮
          Padding(
            padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
            child: SizedBox(
              width: double.infinity,
              height: 44,
              child: ElevatedButton(
                onPressed: () {
                  Navigator.pushNamed(context, '/profile/address/create');
                },
                style: ElevatedButton.styleFrom(
                  backgroundColor: Colors.red,
                  shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(22),
                  ),
                ),
                child: const Text(
                  '新增收货地址',
                  style: TextStyle(fontSize: 16, color: Colors.white),
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
